<html>

<head>
    <script>
        var dojoConfig = {
            paths: {
                "olesk": "/olesk"
            }
        };
    </script>

    <script type="text/javascript"
            src="/dj/dojo/dojo.js"
            data-dojo-config="isDebug:true">
    </script>

    <script type="text/javascript">

    require(["olesk/widgets/TwitterMessage/TwitterMessageWidget",
            "doh",
            "dojo/query",
            "dojo/dom-class",
            "dojo/dom",
            "dojo/dom-construct",
            "dojo/on",
            "dojo/mouse",
            "dojo/robotx",
            "dojo/domReady!"], 
            function (TwitterMessageWidget, doh, query, domClass, dom, domConstruct, on, mouse) {
    	
    	doh.robot.initRobot('./test_base_robot.html');

        doh.register("mouse", [
            {
                name: "mouse_enter",
                setUp: function () {
                    domConstruct.empty("arena");
                },
                tearDown: function () {
                    domConstruct.empty("arena");
                },
                runTest: function () {
                    var twitWidget, def, twitNode;
                    
                    twitWidget = new TwitterMessageWidget({
                        text: "trololo",
                        time: "Wed Apr 11 17:50:17 +0000 2012"
                    });
                    twitWidget.placeAt(dom.byId('arena'));
                    twitNode = query('.b-twitter-message')[0];
                    
                    def = new doh.Deferred();
                    on.once(twitNode, mouse.enter, def.getTestCallback(function () {
                        doh.t(domClass.contains(twitNode, "b-twitter-message_active"));
 	                }));
	                doh.robot.mouseMoveAt(twitNode, 1, 100);
	                return def;
                },
                timeout: 2000
            },
            {
                name: "mouse_enter_and_leave",
                setUp: function () {
                    domConstruct.empty("arena");
                },
                tearDown: function () {
                    domConstruct.empty("arena");
                },
                runTest: function () {
                    var twitWidget, def, twitNode;
                    
                    twitWidget = new TwitterMessageWidget({
                        text: "trololo",
                        time: "Wed Apr 11 17:50:17 +0000 2012"
                    });
                    twitWidget.placeAt(dom.byId('arena'));
                    twitNode = query('.b-twitter-message')[0];
                    
                    def = new doh.Deferred();
                    on.once(twitNode, mouse.leave, def.getTestCallback(function () {
                        doh.f(domClass.contains(twitNode, "b-twitter-message_active"));
                    }));
                    doh.robot.mouseMoveAt(twitNode, 1, 100);
                    doh.robot.mouseMoveAt(dom.byId('out'), 1, 100);
                    return def;
                },
                timeout: 2000
            }
        ]);
        
        doh.run();
    });
    </script>
</head>
<body>
    <div id="arena"></div>
</body>
</html>
